package com.google.gwt.gfx.client.graphics.vml;

import com.google.gwt.gfx.client.graphics.Graphic;
import com.google.gwt.gfx.client.shared.Point;
import com.google.gwt.gfx.client.style.GFXStyle;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;

public class VMLCoordOriginStyle extends GFXStyle {

	public VMLCoordOriginStyle(Graphic g) {
		super(g);
	}

	public VMLCoordOriginStyle(Graphic g, Element element) {
		super(g, element);
	}

	public Point getValue() {
		String[] words = DOM.getElementProperty(element(), "coordorigin")
				.split(",");
		if (words.length != 2) {
			return null;
		}
		Point value = new Point();
		value.setLeft(Integer.parseInt(words[0]));
		value.setTop(Integer.parseInt(words[1]));
		return value;
	}

	public void update(int left, int top) {
		DOM.setElementProperty(element(), "coordorigin", left + "," + top);
	}

}
